package com.jasonzqshen.ifm.editors;


import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.gef.DefaultEditDomain;
import org.eclipse.gef.GraphicalViewer;
import org.eclipse.gef.ui.parts.GraphicalEditor;

import org.eclipse.ui.*;

import com.jasonzqshen.ifm.editparts.FeatureEditPartFactory;
import com.jasonzqshen.ifm.featureModelCore.FeatureModel;
import com.jasonzqshen.ifm.mvc.models.*;
import com.jasonzqshen.ifm.utils.SystemLog;

public class GraphicControlEditor extends GraphicalEditor {
    private DefaultEditDomain editDomain;

    public GraphicControlEditor() {
        editDomain = new DefaultEditDomain(this);
        setEditDomain(this.editDomain);
        SystemLog.logInfo("Graphic Control Editor called.");
    }

    /**
     * Initialize Graphical Viewer
     */
    @Override
    protected void initializeGraphicalViewer() {
        GraphicalViewer viewer = this.getGraphicalViewer();
        IPath loc = ((IFileEditorInput) getEditorInput()).getFile()
                .getLocation();
        SystemLog.logInfo(String.format("Load feature model: %s",
                loc.toString()));

        
        viewer.setContents(new FeatureModelEditPart());
    }

    @Override
    protected void configureGraphicalViewer() {
        super.configureGraphicalViewer();
        GraphicalViewer viewer = getGraphicalViewer();
        viewer.setEditPartFactory(new FeatureEditPartFactory());

        SystemLog.logInfo("Configured Graphical Viewer.");
    }

    @Override
    public void doSave(IProgressMonitor monitor) {
        // TODO Auto-generated method stub

    }

}
